<?php
require '../../config.php';
$query = "SELECT m.nombre,p.insertar,p.seleccionar,p.eliminar,p.abrir,p.imprimir,p.actualizar
					FROM permisos p, modulos m 
					where p.idmodulo= m.idmodulos
					and p.idrol='" .$_REQUEST['idrol']."' and p.idmodulo='" .$_REQUEST['idmodulo']."'";
$result = mysql_query($query,$conexion);  
if(mysql_num_rows($result)>0)
{  
			$data = array();
			while ($row = mysql_fetch_array($result))
			 {
			    $data[] = $row['insertar'];
    			$data[] = $row['seleccionar'];
    			$data[] = $row['eliminar'];
    			$data[] = $row['abrir'];
    			$data[] = $row['imprimir'];
    			$data[] = $row['actualizar'];
    			$data[] = _convert($row['nombre']);
			}
			echo json_encode($data);		
}
function _convert($content) {
	if(!mb_check_encoding($content, 'UTF-8')
	OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {

		$content = mb_convert_encoding($content, 'UTF-8');

		if (mb_check_encoding($content, 'UTF-8')) {
			// log('Converted to UTF-8');
		} else {
			// log('Could not converted to UTF-8');
		}
	}
	return $content;
}
?> 